<!DOCTYPE html>
<html lang="ZH-cn">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Login</title>
  <link rel="stylesheet" href="plugins/layui/css/layui.css">
  <link rel="stylesheet" href="kitAdmin/css/login.css">
</head>

<body>
  <div class="kit-login">
    <div class="kit-login-bg"></div>
    <div class="kit-login-wapper">
      <h2 class="kit-login-slogan">美思英语 <br> 欧美外教一对一</h2>
      <div class="kit-login-form">
        <h4 class="kit-login-title">登录</h4>
        <form class="layui-form">
          <div class="kit-login-row">
            <div class="kit-login-col">
              <i class="layui-icon">&#xe612;</i>
              <span class="kit-login-input">
                <input type="text" name="loginName" lay-verify="required" placeholder="用户名/邮箱/手机号" />
              </span>
            </div>
            <div class="kit-login-col"></div>
          </div>
          <div class="kit-login-row">
            <div class="kit-login-col">
              <i class="layui-icon">&#xe64c;</i>
              <span class="kit-login-input">
                <input type="password" name="password" lay-verify="required" placeholder="密码" />
              </span>
            </div>
            <div class="kit-login-col"></div>
          </div>
          <div class="kit-login-row">
            <div class="kit-login-col">
              <input type="checkbox" name="rememberMe" title="记住帐号" lay-skin="primary">
            </div>
          </div>
          <div class="kit-login-row">
            <button class="layui-btn kit-login-btn" lay-submit="submit" lay-filter="login_hash">登录</button>
          </div>
          <div class="kit-login-row" style="margin-bottom:0;">
            <a href="javascript:;" style="color: rgb(153, 153, 153); text-decoration: none; font-size: 13px;" id="forgot">忘记密码</a>
          </div>
        </form>
      </div>
    </div>
  </div>
  <script src="static/js/base.js" type="text/javascript" charset="utf-8"></script>
  <script src="plugins/polyfill.min.js"></script>
  <script src="plugins/layui/layui.js"></script>
  <script src="http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.js"></script>

  <script>
    layui.use(['layer', 'form'], function() {
      var form = layui.form,
        $ = layui.jquery;

      $('#forgot').on('click', function() {
        layer.msg('请联系管理员.');
      });
      //监听提交
      form.on('submit(login_hash)', function(data) {
        //layer.msg(JSON.stringify(data.field));//显示用户名和密码
        // $.ajax({
			// url:'/login/',
			// type:'get',
			// success:function(data){
			// 	$.link(true, ".kit-table", data.data);
			// 	$('select').select2().change();
			// },
			// error:function(){
			// 	parent.layer.alert('系统或网络错误！');
			// }
        // });
//         2018-9-25 chenbin: session测试通过，先注释，后期需完善
//         $.ajax({
// 			url:'/login/setUID/'+"UniqueIdTest",
// 			type:'POST',
// 			success:function(data){
				
// 			},
// 			error:function(){
				
// 			}
// 		});
//           var encrypt = new JSEncrypt();
          // encrypt.setPublicKey("MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKgw2UJlI+XJTQTbvc7H9+xESMP8J7pbNXf9AvpR3xwHslg3ftKzoIqOhKjcOOgajWxEq4oGnrv95yPIFT6l/PsCAwEAAQ==");
          // data.field.password = encrypt.encrypt(data.field.password);
          data.field.password = md5(data.field.password);
          $.ajax({
              url: baseUrl+'/login/check',
              method: 'POST',
              data: {
                  loginName: data.field.loginName,
                  password: data.field.password
              },
              dataType:"json",
              success:function(data){
                  if(data && data.code == 0){
                      location.href = baseUrl+data.data.return_to;
                  }else {
                      parent.layer.alert('登录失败！');
                  }
              },
              error:function(){
                  parent.layer.alert('系统或网络错误！');
              }
          });

        // setTimeout(function(){
        //     location.href='view/Teacher.html';
        // },1000);
        return false;
      });
    });
  </script>
</body>

</html>